package cn.tedu._05mvcboot02.exception;

import cn.tedu._05mvcboot02.common.response.JsonResult;
import cn.tedu._05mvcboot02.common.response.StatusCode;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;
@RestControllerAdvice
public class GlobalExceptionHandler {
    @ExceptionHandler
    public JsonResult doIllegalArgumentException(IllegalArgumentException ex){
        String data = ex.getMessage();
        return new JsonResult(StatusCode.OPERATION_FAILED,data);
    }
    @ExceptionHandler
    public JsonResult doRuntimeException(RuntimeException ex){
        String data = ex.getMessage();
        return new JsonResult(StatusCode.OPERATION_FAILED,data);
    }
}
